import 'package:dio/dio.dart';
import 'package:x3_base_core/base_configs/service_config.dart';
import 'package:x3_base_core/base_utils/base_storage_util.dart';
import 'package:x3_base_core/base_configs/dio_interceptor_config.dart';

/// 请求头拦截 设置发送请求超时时间  响应请求的超时时间  请求头  基地址
class BaseHeadersInterceptor extends InterceptorsWrapper {

  @override
  void onRequest(RequestOptions options, RequestInterceptorHandler handler) {

    /// 设置超时时间
    options.connectTimeout = DioInterceptorConfig.connectTimeout;

    /// 设置响应时间
    options.receiveTimeout = DioInterceptorConfig.receiveTimeout;

    /// 设置请求权限
    options.headers['authorization'] = BaseStorageUtil.getAuthorization();

    /// 设置请求权限
    options.headers['cloud-authorization'] = BaseStorageUtil.getCloudAuthorization();

    /// 设置请求的基地址
    options.baseUrl = ServiceConfig.x3ServiceGatewayCenter;

    super.onRequest(options, handler);

  }

}
